采用 VSTO(Visual Studio Tools for Office ),实现类似百度搜索功能,所有文档数据存储在数据库中
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.Office.Tools.Ribbon;using System.Windows.Forms;using WordSearch.CustomUserControls;using Microsoft.Office.Core;namespace WordSearch{ public partial class StrSearch { internal Microsoft.Office.Tools.CustomTaskPane helpTaskPane; private void StrSearch_Load(object sender, RibbonUIEventArgs e) { } private void btnSearch_Click(object sender, RibbonControlEventArgs e) { if (helpTaskPane == null) { //MessageBox.Show("111"); // 把自定义窗体添加到CustomTaskPanes集合中 // UserControl1 是一个自定义控件类 //helpTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new UserControl2(), "数据检索"); //helpTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(new UserControl1(), "数据检索"); //// 使任务窗体可见 //helpTaskPane.Visible = true; //// 通过DockPosition属性来控制任务窗体的停靠位置, //// 设置为 MsoCTPDockPosition.msoCTPDockPositionRight这个代表停靠到右边,这个值也是默认值 //helpTaskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionLeft; //helpTaskPane.Width = 540; SearchControl serachControl = new SearchControl() { Dock = DockStyle.Fill }; helpTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(serachControl, "数据检索"); helpTaskPane.DockPosition = MsoCTPDockPosition.msoCTPDockPositionLeft; helpTaskPane.Width = 750; helpTaskPane.Visible = true; } else if(helpTaskPane.Visible == false) { helpTaskPane.Visible = true; } } }}
评论